<?php

//权限认证
class l_auth
{
    static public $model = null; //数据库模型
    static public function auth_operate($model, $id)
    {

        if (empty($id)) {
        } else {
            self::$model = $model;
            require '../inc/config.php';

            if ($_SESSION[$config['spot'] . 'admin_gid'] == 1) {
                //判断是否超级管理员组
                return true;
            }

            $group_info = self::$model->table('admin_group')->where('id=' . $_SESSION[$config['spot'] .'admin_gid'])->find();//取出权限信息

            if ($group_info['power_value'] == -1 || in_array($id, explode(',', $group_info['power_value']))) {
                return true;
            } else {
                return false;
            }

        }

    }

    static public function auth_class($model, $id, $cid)
    {

        if (empty($cid)) {
        } else {
            self::$model = $model;
            require '../inc/config.php';

            if ($_SESSION[$config['spot'] . 'admin_gid'] == 1) {
                //判断是否超级管理员组
                return true;
            }

            $group_info = self::$model->table('admin_group')->where('id=' . $_SESSION[$config['spot'] .'admin_gid'])->find();//取出权限信息
            $auth_info = self::$model->table('resource')->field('id,cid')->where('cid=' . $cid)->find(); //取出栏目该下的信息权限
            if ($group_info['power_value'] == -1 || in_array($auth_info['id'], explode(',', $group_info['power_value']))) {
                return true;
            } else {
                return false;
            }

        }


    }

}

?>